﻿using System;
using System.Collections.Generic;

namespace LocalOverride.Fiddler.Store
{
    class FilePathValidator : IValidator
    {
        private readonly MappingEntry mappingEntry;
        private readonly ILocalFileAccess localFileAccess;

        public FilePathValidator(MappingEntry mappingEntry, ILocalFileAccess localFileAccess)
        {
            this.mappingEntry = mappingEntry;
            this.localFileAccess = localFileAccess;
        }

        public ValidationResult Validate()
        {
            if(localFileAccess.IsValidFilename(mappingEntry.LocalPath))
            {
                return ValidationResult.Valid;
            }
            else
            {
                return new ValidationResult(false, new ErrorNotification("LocalPath", "Invalid File Path"));
            }
        }
    }
}